package exception_homework2;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * PWDemo2简要记事本按行写
 */
public class PWDemo3 {
    public static void main(String[] args) throws FileNotFoundException {
       FileOutputStream fos = new FileOutputStream("fos5.dat");
       OutputStreamWriter os = new OutputStreamWriter(fos,StandardCharsets.UTF_8);
       BufferedWriter bw = new BufferedWriter(os);
       PrintWriter pw = new PrintWriter(bw,true);
       Scanner scanner = new Scanner(System.in);
        System.out.println("请输入文字,以单独输出exit退出");
       while (true){
           String line = scanner.nextLine();
           if ("exit".equals(line)){
               System.out.println("输出完成..");
               break;
           }
           pw.write(line);
       }
       pw.close();

    }
}
